﻿//function DeleteNoticeSelection() {
//  if (confirm("确定要删除所选项目吗？")) {
//    var arr = [];
//    var chblist = document.getElementsByName("p_chkb");
//    for (var i = 0; i < chblist.length; i++) {
//      if (chblist[i].checked) {
//        arr.push(chblist[i].value);
//      }
//    }
//    if (arr.length == 0) {
//      alert("未选择任何项目吗");
//    } else {
//      document.getElementById("arrv").value = arr;
//      document.getElementById("form1").action = "/sys/notice/Delete.aspx?act=d";
//      document.getElementById("form1").submit();
//    }
//  }
//}

//function DeleteQnASelection() {
//  if (confirm("确定要删除所选项目吗？")) {
//    var arr = [];
//    var chblist = document.getElementsByName("p_chkb");
//    for (var i = 0; i < chblist.length; i++) {
//      if (chblist[i].checked) {
//        arr.push(chblist[i].value);
//      }
//    }
//    if (arr.length == 0) {
//      alert("未选择任何项目吗");
//    } else {
//      document.getElementById("arrv").value = arr;
//      document.getElementById("form1").action = "/sys/qna/Delete.aspx?act=d";
//      document.getElementById("form1").submit();
//    }
//  }
//}

function DeleteSysSelection(key) {
  if (confirm("确定要删除所选项目吗？")) {
    var arr = [];
    var chblist = document.getElementsByName("p_chkb");
    for (var i = 0; i < chblist.length; i++) {
      if (chblist[i].checked) {
        arr.push(chblist[i].value);
      }
    }
    if (arr.length == 0) {
      alert("未选择任何项目吗");
    } else {
      var path = "";
      switch (key) {
        case "feedback":
          path = "feedback";
          break;
        case "notice":
          path = "notice";
          break;
        case "qna":
          path = "qna";
          break;
        default:
          break;
      }
      if (path != "") {
        document.getElementById("arrv").value = arr;
        document.getElementById("form1").action = "/sys/" + path + "/Delete.aspx?act=d";
        document.getElementById("form1").submit();
      } else {
        return;
      }
    }
  }
}

function CheckNoticeForm() {
  var title = $("#Title").val();
  var categoryid = $("#CategorySlt").val();
  var sys = $("#SysSlt").val();
  //  var content = $("#ContentTxt").val();

  var Editor = FCKeditorAPI.GetInstance("ContentTxt");

  var content = Editor.GetXHTML(false);

  var err = false;

  if (title == "" || categoryid == "-1" || sys == "-1" || content == "") {
    alert("请完整填写公告信息");
    err = true;
  }

  var areaArr = [];
  var isChecked = false;
  var areaList = document.getElementsByName("AreaChb");
  for (var i = 0; i < areaList.length; i++) {
    if ($("#AreaChb_" + i)[0].checked) {
      isChecked = true;
      areaArr.push($("#AreaChb_" + i).val());
    }
  }

  if (!isChecked) {
    alert("请至少选择一个地区");
    err = true;
  }

  $("#area_v").val(areaArr);

  if (err) {
    return false;
  } else {
    return true;
  }
  
}